{extend name="public/base"}

{block name="title"}
设置
{/block}

{block name="style"}
{css href="/static/wechat/css/set.css" /}
{/block}

{block name="body"}
<div class="pageControl verify">
    <div class="msui_nav msui_navTop">
        <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
        <h1 class="msui_navTop-title">身份验证</h1>
    </div>
    <div class="weui-top">
        <div class="weui-msg">
            <div class="weui-msg__text-area">
                <h2 class="weui-msg__title cl-3333 fs085">修改手机需要验证您的身份</h2>
                <p class="fs075 cl-9999">验证码将发送到:<span class="js-message">{$phone}</span></p>
            </div>
        </div>
        <form>
            <div class="weui-cells weui-cells_form">
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">验证码</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="number"  placeholder="请输入验证码">
                    </div>
                    <div class="weui-cell_ft">
                        <button class="weui_cell-verify js-verify cl-orange">获取验证码</button>
                    </div>
                </div>
            </div>
            <div class="msui_button">
                <div class="msui_button-bd">
                    <a href="javascript:;" class="msui_button-content">下一步</a>
                </div>
            </div>
            <input type="hidden" name="phone" value="{$phone}">
        </form>
    </div>


</div>
{/block}

{block name="javascript"}
<script>
    $(function () {
        $(".msui_button-content").click(function () {
            // 先验证验证码是否正确
            var code = $(".weui-input").val();
            var phone = {$phone};
            var action = '{$action}';
            var type = '{$type}';
            $.get("{:url('base/check_code')}", {code : code, phone : phone}, function (msg) {
                console.log(msg);
                if(msg.code == 200) {
                    window.location.href = '/wechat/set/'+action+'/check_code/' + code + '/type/' + type;
                } else {
                    var e_code = msg.code;
                    $.alert(error_code[e_code]);
                }
            })
        });
    });
</script>
{/block}